package com.syzg.common.service.impl;

import com.syzg.common.dao.BaseDAO;
import com.syzg.common.service.BaseService;
import com.syzg.common.util.SearchMap;
import com.syzg.core.exception.ServiceException;
import com.syzg.core.page.PageResult;
import java.io.Serializable;
import java.util.List;
import org.apache.log4j.Logger;

public class BaseServiceImpl<T>
  implements BaseService<T>
{
  public Logger logger;
  private BaseDAO<T> DAO;

  public BaseServiceImpl()
  {
    this.logger = Logger.getLogger(getClass());
  }

  public BaseDAO<T> getDAO()
  {
    return this.DAO;
  }

  public void setDAO(BaseDAO<T> dao)
  {
    this.DAO = dao;
  }

  public T findObjectById(Serializable id)
    throws ServiceException
  {
    return this.DAO.findObjectById(id);
  }

  public Object findObjectById(Serializable id, Class<?> objectClass)
    throws ServiceException
  {
    return this.DAO.findObjectById(id, objectClass);
  }

  public void delete(Object object)
    throws ServiceException
  {
    this.DAO.delete(object);
  }

  public void delete(Serializable id)
    throws ServiceException
  {
    this.DAO.delete(id);
  }

  public void delete(Serializable id, Class<?> objectClass)
    throws ServiceException
  {
    this.DAO.delete(id, objectClass);
  }

  public void delete(Serializable[] ids)
    throws ServiceException
  {
    this.DAO.delete(ids);
  }

  public void delete(Serializable[] ids, Class<?> objectClass)
    throws ServiceException
  {
    this.DAO.delete(ids, objectClass);
  }

  public void update(Object object)
    throws ServiceException
  {
    this.DAO.update(object);
  }

  public void create(Object object) throws ServiceException
  {
    this.DAO.create(object);
  }

  public List findObjects(SearchMap searchMap)
    throws ServiceException
  {
    return this.DAO.findObjects(searchMap);
  }

  public long getCount(SearchMap searchMap) throws ServiceException {
    return this.DAO.getCount(searchMap);
  }

  public boolean isExist(Serializable id, String[] propertyNames, String[] propertyValues) throws ServiceException
  {
    return this.DAO.isExist(id, propertyNames, propertyValues);
  }

  public boolean isExist(Serializable id, String[] propertyNames, String[] propertyValues, Class<?> objectClass) throws ServiceException
  {
    return this.DAO.isExist(id, propertyNames, propertyValues, objectClass);
  }

  public PageResult findObjectsForPage(int pageNo, int pageSize, SearchMap searchMap) throws ServiceException {
    if (pageNo < 1) {
      pageNo = 1;
    }
    return this.DAO.findObjectsForPage(pageNo, pageSize, searchMap);
  }
}